﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace com.demo
{
    public class UploadProgressEditor
        : System.Drawing.Design.UITypeEditor
    {
        public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return System.Drawing.Design.UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            System.Windows.Forms.Design.IWindowsFormsEditorService wfe
                = provider.GetService(
                typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)
                )
                as System.Windows.Forms.Design.IWindowsFormsEditorService;
            if (wfe != null)
            {
                UploadProgress progress = value as UploadProgress;
                com.demo.UploadProgressForm form
                    = new UploadProgressForm(
                        progress.Enabled,
                        progress.DueTime,
                        progress.Period,
                        progress.CallbackFunc
                        );
                using (form)
                {
                    wfe.ShowDialog(form);
                    UploadProgress result = new UploadProgress();
                    result.Enabled = form.AjaxEnabled;
                    result.DueTime = form.DueTime;
                    result.Period = form.Period;
                    result.CallbackFunc = form.CallbackFunc;
                    return result;


                }
            }


            return base.EditValue(context, provider, value);
        }
    }
}
